﻿using PagedList;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WordDocumentGenerator.Library;

namespace GPS.ENTITYS
{
    public class ExportBC_ToChucSatHach
    {
        [Display(Name = "pDVGTVT_MA")]
        public string pDVGTVT_MA { get; set; }
        public string KH_SOQDKG { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_NGAYQDKG { get; set; }
        public string DTSH_CSDT_DVGTVT_MA { get; set; }
        public string DTSH_CSDT_KH_MA { get; set; }
        public string DTSH_CSDT_KH_LOP_MA { get; set; }
        public string DTSH_CSDT_HGPLX_MA { get; set; }
        public List<Export_BC_TC_ThiMoi> LIST_THIMOI { get; set; }
        public List<Export_BC_TC_ChuaThi> LIST_CHUATHI { get; set; }
        public List<Export_BC_TC_VangThi> LIST_VANGTHI { get; set; }
        public List<Export_BC_TC_ThiLai> LIST_THILAI { get; set; }
    }

    public class Export_BC_TC_ThiMoi
    {
        public string KH_SOQDKG { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_NGAYQDKG { get; set; }
        public string DTSH_CSDT_DVGTVT_MA { get; set; }
        public string DTSH_CSDT_KH_MA { get; set; }
        public string DTSH_CSDT_KH_LOP_MA { get; set; }
        public string DTSH_CSDT_HGPLX_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYBD { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYKT { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? KH_LOP_TONGHV { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? SH_TONGHV { get; set; }
        public string LUAT { get; set; }
        public string HINH { get; set; }

    }

    public class Export_BC_TC_ChuaThi
    {
        public string KH_SOQDKG { get; set; }
        public DateTime? KH_NGAYQDKG { get; set; }
        public string DTSH_CSDT_DVGTVT_MA { get; set; }
        public string DTSH_CSDT_KH_MA { get; set; }
        public string DTSH_CSDT_KH_LOP_MA { get; set; }
        public string DTSH_CSDT_HGPLX_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYBD { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYKT { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? KH_LOP_TONGHV { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? SH_TONGHV { get; set; }
        public string LUAT { get; set; }
        public string HINH { get; set; }
    }

    public class Export_BC_TC_VangThi
    {
        public string KH_SOQDKG { get; set; }
        public DateTime? KH_NGAYQDKG { get; set; }
        public string DTSH_CSDT_DVGTVT_MA { get; set; }
        public string DTSH_CSDT_KH_MA { get; set; }
        public string DTSH_CSDT_KH_LOP_MA { get; set; }
        public string DTSH_CSDT_HGPLX_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYBD { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYKT { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? KH_LOP_TONGHV { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? SH_TONGHV { get; set; }
        public string LUAT { get; set; }
        public string HINH { get; set; }
    }

    public class Export_BC_TC_ThiLai
    {
        public string KH_SOQDKG { get; set; }
        public DateTime? KH_NGAYQDKG { get; set; }
        public string DTSH_CSDT_DVGTVT_MA { get; set; }
        public string DTSH_CSDT_KH_MA { get; set; }
        public string DTSH_CSDT_KH_LOP_MA { get; set; }
        public string DTSH_CSDT_HGPLX_MA { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYBD { get; set; }
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime? KH_LOP_NGAYKT { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? KH_LOP_TONGHV { get; set; }
        [DisplayFormat(DataFormatString = "{0:0}", ApplyFormatInEditMode = true)]
        public Int32? SH_TONGHV { get; set; }
        public string LUAT { get; set; }
        public string HINH { get; set; }
    }

    public class EXPORTWORD_BC_ToChucSatHach
    {
        public static byte[] EXPORT_OPENDOOR(string templateFileName, object objSource, string docType)
        {
            DocumentGenerationInfo generationInfo = GetDocumentGenerationInfo(docType, "1.0", objSource, templateFileName, false);

            COMMON.ExportCore<ExportBC_ToChucSatHach> docGenerator = new COMMON.ExportCore<ExportBC_ToChucSatHach>(generationInfo);

            return docGenerator.GenerateDocument();
        }
        /// <summary>
        /// Gets the document generation info.
        /// </summary>
        /// <param name="docType">Type of the doc.</param>
        /// <param name="docVersion">The doc version.</param>
        /// <param name="dataContext">The data context.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <param name="useDataBoundControls">if set to <c>true</c> [use data bound controls].</param>
        /// <returns></returns>
        private static DocumentGenerationInfo GetDocumentGenerationInfo(string docType, string docVersion, object dataContext, string fileName, bool useDataBoundControls)
        {
            DocumentGenerationInfo generationInfo = new DocumentGenerationInfo();
            generationInfo.Metadata = new DocumentMetadata
            {
                DocumentType = docType,
                DocumentVersion = docVersion
            };
            generationInfo.DataContext = dataContext;
            generationInfo.TemplateData = File.ReadAllBytes(fileName);
            generationInfo.IsDataBoundControls = useDataBoundControls;

            return generationInfo;
        }

    }
}
